package com.ruoyi.system.view.common;

import com.alibaba.fastjson2.function.impl.ToDouble;

import java.io.Serializable;

public class Result<T> implements Serializable {
    private Integer code = 200;
    private T data;
    private String msg;

    public static <T> Result<T> success(T object,String msg) {
        Result<T> r = new Result<T>();
        r.data = object;
        r.msg = msg;
        return r;
    }
    public static <T> Result<T> error(T object,Integer code,String msg) {
        Result<T> r = new Result<T>();
        r.data = object;
        r.code = code;
        r.msg = msg;
        return r;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", data=" + data +
                ", msg='" + msg + '\'' +
                '}';
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
